'use strict';

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const { router, controller, middleware } = app;
  const { auth } = middleware;

  // 上传
  router.post('/api/upload/file', controller.oss.ali.upload);

  // 客户
  router.post('/api/member/wxlogin', controller.member.wxlogin);
  router.post('/api/member/wxH5login', controller.member.wxH5login);
  router.post('/api/member/login', controller.member.login);
  router.post('/api/member/register', controller.member.create);
  // 广告轮播
  router.get('/api/banner/list', controller.banner.allList);
  router.resources('banner', '/api/banner', controller.banner);
  // 客服
  router.get('/api/staff/serveTime', controller.staff.serveTime);
  router.post('/api/staff/login', controller.staff.login);
  router.get('/api/staff/list', controller.staff.allList);
  router.resources('staff', '/api/staff', controller.staff);
  // 客服余额
    router.get('/api/staffBalance/list', controller.staffBalance.allList);
  router.post('/api/staffBalance/audit', controller.staffBalance.audit);
    router.resources('staffBalance', '/api/staffBalance', controller.staffBalance);

  // 后台用户
  router.post('/api/admin/login', controller.user.login);
  router.get('/api/user/list', controller.user.allList);
  router.resources('user', '/api/user', controller.user);
  // 角色
  router.get('/api/role/list', controller.role.allList);
  router.resources('role', '/api/role', controller.role);

  // 优惠券
  router.get('/api/coupon/list', controller.coupon.allList);
  router.resources('coupon', '/api/coupon', controller.coupon);
  // 优惠券领取
  router.get('/api/couponMember/list', controller.couponMember.allList);
  router.resources('couponMember', '/api/couponMember', controller.couponMember);
  // 客服收藏
  router.get('/api/staffCollect/list', controller.staffCollect.allList);
  router.resources('staffCollect', '/api/staffCollect', controller.staffCollect);
  // 客服申请
    router.get('/api/staffApply/list', controller.staffApply.allList);
    router.resources('staffApply', '/api/staffApply', controller.staffApply);
  // 项目收藏
    router.get('/api/projectCollect/list', controller.goodsCollect.allList);
    router.resources('projectCollect', '/api/projectCollect', controller.goodsCollect);
  // 服务分类
  router.get('/api/category/list', controller.category.allList);
  router.resources('category', '/api/category', controller.category);
  // 商品
  router.get('/api/project/list', controller.goods.allList);
  router.resources('project', '/api/project', controller.goods);
  // 付款
  router.post('/api/payment/pay', controller.payment.pay);
  router.post('/api/payment/payRecharge', controller.payment.payRecharge);
  router.post('/api/payment/wxnotify', controller.payment.wxnotify);
  router.get('/api/payment/wxnotify', controller.payment.wxnotify);
  router.post('/api/payment/wxnotifyRecharge', controller.payment.wxnotifyRecharge);
  router.post('/api/payment/wxnotifyRefund', controller.payment.wxnotifyRefund);
  router.post('/api/order/refund', controller.orderGoods.refund);
  // /**
  //  * 公众号支付
  //  */
  // router.post('/api/paymentH5/pay', controller.paymentH5.pay);
  // router.post('/api/paymentH5/payRecharge', controller.paymentH5.payRecharge);
  // router.post('/api/paymentH5/wxnotify', controller.paymentH5.wxnotify);
  // router.post('/api/paymentH5/wxnotifyRecharge', controller.paymentH5.wxnotifyRecharge);
  // router.post('/api/paymentH5/wxnotifyRefund', controller.paymentH5.wxnotifyRefund);
  // router.post('/api/order/refundH5', controller.orderGoods.refundH5);
  // 商品订单
  router.get('/api/order/list', controller.orderGoods.allList);
  // 订单支付状态更新
  router.post('/api/order/updatePayStatus', controller.orderGoods.updatePayStatus);
  router.resources('order', '/api/order', controller.orderGoods);
  // 订单商品详情
  router.get('/api/orderDetail/list', controller.orderGoodsDetail.allList);
  router.resources('orderDetail', '/api/orderDetail', controller.orderGoodsDetail);
  // 会员
  router.get('/api/member/list', controller.member.allList);
  router.resources('member', '/api/member', controller.member);
  // 地址
  router.get('/api/address/list', controller.address.allList);
  router.get('/api/address/default', controller.address.defaultOne);
  router.post('/api/address/updateStatus', controller.address.updateStatus);
  router.resources('address', '/api/address', controller.address);
  // 评论
  router.get('/api/comment/list', controller.comment.allList);
  router.resources('comment', '/api/comment', controller.comment);
  // 评论
  router.get('/api/staffComment/list', controller.staffComment.allList);
  router.resources('staffComment', '/api/staffComment', controller.staffComment);
  // 评论
  router.get('/api/projectComment/list', controller.projectComment.allList);
  router.resources('projectComment', '/api/projectComment', controller.projectComment);
  // Consult
  router.get('/api/consult/list', controller.consult.allList);
  router.resources('consult', '/api/consult', controller.consult);
  // city
  router.get('/api/city/list', controller.city.allList);
  router.resources('city', '/api/city', controller.city);
  // travelMode
    router.get('/api/travelMode/list', controller.travelMode.allList);
    router.resources('travelMode', '/api/travelMode', controller.travelMode);
    // policy
    router.get('/api/policy/list', controller.policy.allList);
    router.resources('policy', '/api/policy', controller.policy);
};
